package leetcode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2022-02-16
 * Time: 12:59
 */
public class Day_03_02 {
    public static void main(String[] args) {

    }
}
class MinStack {

    Stack<Integer> A,B;
    public MinStack() {
        A=new Stack<>();
        B=new Stack<>();

    }

    public void push(int x) {
        A.add(x);
        if(B.isEmpty()||B.peek()>=x){
            B.add(x);
        }

    }

    public void pop() {
        if(A.pop().equals(B.peek())){
            B.pop();
        }

    }

    public int top() {
        return A.peek();
    }

    public int min() {
        return B.peek();
    }
}

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(x);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.min();
 */
